<%@ include file="/common/taglibs.jsp"%>

<head>
    <title><fmt:message key="authorityDetail.title"/></title>
    <meta name="heading" content="<fmt:message key='authorityDetail.heading'/>"/>
</head>

<c:set var="delObject" scope="request"><fmt:message key="authorityList.authority"/></c:set>
<script type="text/javascript">var msgDelConfirm =
   "<fmt:message key="delete.confirm"><fmt:param value="${delObject}"/></fmt:message>";
</script>

<div class="span2">
    <h2><fmt:message key="authorityDetail.heading"/></h2>
    <fmt:message key="authorityDetail.message"/>
</div>

<div class="span7">
    <s:form id="authorityForm" action="saveAuthority" method="post" validate="true" cssClass="well form-horizontal">
            <s:hidden key="authority.id"/>
        <s:textfield key="authority.name" required="true" maxlength="50" />

        <div id="actions" class="form-actions">
            <s:submit type="button" cssClass="btn btn-primary" method="save" key="button.save" theme="simple">
                <i class="icon-ok icon-white"></i> <fmt:message key="button.save"/>
            </s:submit>
            <c:if test="${not empty authority.id}">
                <s:submit type="button" cssClass="btn btn-warning" method="delete" key="button.delete"
                    onclick="return confirmMessage(msgDelConfirm)" theme="simple">
                    <i class="icon-trash icon-white"></i> <fmt:message key="button.delete"/>
                </s:submit>
            </c:if>
            <s:submit type="button" cssClass="btn" method="cancel" key="button.cancel" theme="simple">
                <i class="icon-remove"></i> <fmt:message key="button.cancel"/>
            </s:submit>
        </div>
    </s:form>
    <c:if test="${not empty authority.id}">
     <h2>Systemusers</h2>
	    <s:form id="systemuseAuthoritiesForm" action="addAuthoritySystemUser" method="post" validate="true" cssClass="well form-horizontal">
	        <s:hidden key="authority.id"/>
	     	<s:select name="systemuser.id" list="systemuserList" listKey="id" listValue="name"  label="Systemusers"></s:select>
	     	 <div id="actions" class="form-actions">
	        <s:submit type="button" cssClass="btn btn-primary" method="addAuthoritySystemUser" key="button.save" theme="simple">
	            <i class="icon-ok icon-white"></i> add
	        </s:submit>
	        </div>
		</s:form>
		<display:table name="authority.systemusers" class="table table-condensed table-striped table-hover" requestURI="" id="systemuserList" export="true" pagesize="25">
        <display:column property="id" sortable="true" href="editSystemuser" media="html"
            paramId="id" paramProperty="id" titleKey="systemuser.id"/>
        <display:column property="id" media="csv excel xml pdf" titleKey="systemuser.id"/>
        <display:column property="username" sortable="true" titleKey="systemuser.username"/>
        <display:column property="name" sortable="true" titleKey="systemuser.name"/>
        <display:column property="password" sortable="true" titleKey="systemuser.password"/>
        <display:column property="type" sortable="true" titleKey="systemuser.type"/>
	      <display:column>
	       <s:form id="systemuseAuthoritiesForm" action="deleteAuthoritySystemUser" method="post" validate="true">
			    <s:hidden key="authority.id"/>
			    <s:hidden value="%{#attr.systemuserList.id}" name="systemuser.id"/>
			    <s:submit type="button" cssClass="btn btn-primary" method="deleteAuthoritySystemUser" key="button.delete" theme="simple">
			        <i class="icon-ok icon-white"></i> delete
			    </s:submit>
			</s:form>
      	</display:column>

        <display:setProperty name="paging.banner.item_name"><fmt:message key="systemuserList.systemuser"/></display:setProperty>
        <display:setProperty name="paging.banner.items_name"><fmt:message key="systemuserList.systemusers"/></display:setProperty>
    </display:table>
    </c:if>
</div>

<script type="text/javascript">
    $(document).ready(function() {
        $("input[type='text']:visible:enabled:first", document.forms['authorityForm']).focus();
    });
</script>
